package edu.cuit.avatar.loop;

import java.util.Scanner;

/**
 * 计算个数不确定的整数和
 *
 */
public class SentinelValue {
    public static void main(String[] args) {
        int sum = 0;
        Scanner input = new Scanner(System.in);
        System.out.println("请输入一个整数,0退出");
        int number = input.nextInt();
        while(number != 0){
            sum += number;
            System.out.println("请输入一个整数,0退出");
            number = input.nextInt();
        }
        System.out.println("sum = " + sum);
    }
}
